package com.smart.transactional;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author junrui.wang
 * @create 2018/6/11
 */
@Service
public class Service2 {
    @Resource
    private JdbcTemplate jdbcTemplate;

    @Transactional
    public void createData(){
        jdbcTemplate.update("insert into user(id, name) VALUES ('1', 'name')");

        createData2();

    }

    @Transactional
    public void createData2(){
        jdbcTemplate.update("insert into user(id, name) VALUES ('1', 'name')");
    }
}
